<?php
//测试控制器类
class IndexController extends Controller{
    public $user;

    public function __init(){
        //判断用户是否登录
        $user = Q('session.user');
        if(empty($user)){
            header('location:'.u('login/login'));
        }else{
            /*判断登陆信息日志ip*/
            $where = 'uid = '.$user['uid'];
            $loginfo = K('user') -> selclog($where);
            if($loginfo['logip'] != $_SESSION['logip']){
                unset($_SESSION['user']);
                $this -> success($message = '您的账户已从另一个地方登陆！',U('login/login'), $time = 2);
            }
        }
        $this -> assign('user',$user);
    }
    //动作方法
    public function index(){
        //显示视图
        $this->display('Template/user/header');
        $this->display();
    }
}
